package cn.com.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import cn.com.biz.LiuYanBiz;
import cn.com.entity.LiuYan;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;

public class LiuYanAction extends ActionSupport implements Action,SessionAware{
	Map<String, Object> session;
	
	public Map<String, Object> getSession() {
		return session;
	}

	@Override
	public void setSession(Map<String, Object> arg0) {
		session=arg0;	
	}
	private LiuYanBiz liuyanBiz;
	private LiuYan liuyan;
	
	public LiuYan getLiuyan() {
		return liuyan;
	}

	public void setLiuyan(LiuYan liuyan) {
		this.liuyan = liuyan;
	}

	public LiuYanBiz getLiuyanBiz() {
		return liuyanBiz;
	}

	public void setLiuyanBiz(LiuYanBiz liuyanBiz) {
		this.liuyanBiz = liuyanBiz;
	}
	public String getall(){
		ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml");
		liuyanBiz=(LiuYanBiz)ctx.getBean("liuyanBiz");
		List<LiuYan> liuyanlist=liuyanBiz.getall();
		if(liuyanlist!=null){
			session.put("liuyanlist", liuyanlist);
			return SUCCESS;
		}else{
			return ERROR;
		}
	}
	public String insertliuyan(){
		boolean b=liuyanBiz.insertliuyan(liuyan);
		if(b){
			return SUCCESS;
		}else{
			return ERROR;
		}
	}
}
